package expriment4_T4;

public class Rectangle {
    int height;
    int width;

    public Rectangle() {
    }

    public Rectangle(int height, int width) {
        this.height = height;
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int area() {
        return width * height;
    }
    public  int  zhouchang(){
        return (width+height)*2;
    }
}
class RectangleDemo{
    public static void main(String[] args) {
        System.out.println("无参函数如下：");
        Rectangle r1=new Rectangle();
        r1.setHeight(8);
        r1.setWidth(10);
        System.out.println("Rectangle[height="+r1.getWidth()+",width="+r1.getHeight()+"]");
        System.out.println("周长为："+r1.zhouchang());
        System.out.println("面积为："+r1.area());
        System.out.println("------------------");
        System.out.println("有参函数如下：");
        Rectangle r2=new Rectangle(9,12);
        System.out.println("Rectangle[height="+r2.getWidth()+",width="+r2.getHeight()+"]");
        System.out.println("周长为："+r2.zhouchang());
        System.out.println("面积为："+r2.area());
    }
}
